/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cuadroanotacion.start;

import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel;
import org.cuadroanotacionapi.beans.Jos_fastball_gamestatus;
import org.cuadroanotacionapi.beans.Jos_fastball_gametype;
import org.cuadroanotacionapi.beans.Jos_fastball_linescore;
import org.cuadroanotacionapi.beans.Jos_fastball_location;
import org.cuadroanotacionapi.beans.Jos_fastball_player;
import org.cuadroanotacionapi.beans.Jos_fastball_playerstat;
import org.cuadroanotacionapi.beans.Jos_fastball_schedule;
import org.cuadroanotacionapi.beans.Jos_fastball_season;
import org.cuadroanotacionapi.beans.Jos_fastball_team;
import org.cuadroanotacionapi.controller.*;
import org.cuadroanotacionapi.generales.Mensajeria;

/**
 *
 * @author avbravo
 */
public class LivescoreFrame extends javax.swing.JInternalFrame {

    Jos_fastball_schedule jos_fastball_schedule1 = new Jos_fastball_schedule();
    Jos_fastball_scheduleController jos_fastball_scheduleController1 = new Jos_fastball_scheduleController();
    Jos_fastball_team jos_fastball_team1 = new Jos_fastball_team();
    Jos_fastball_teamController jos_fastball_teamController1 = new Jos_fastball_teamController();
    Jos_fastball_gametype jos_fastball_gametype1 = new Jos_fastball_gametype();
    Jos_fastball_gametypeController jos_fastball_gametypeController1 = new Jos_fastball_gametypeController();
    Jos_fastball_location jos_fastball_location1 = new Jos_fastball_location();
    Jos_fastball_locationController jos_fastball_locationController1 = new Jos_fastball_locationController();
    
    Jos_fastball_season jos_fastball_season1 = new Jos_fastball_season();
    Jos_fastball_seasonController jos_fastball_seasonContoller1 = new Jos_fastball_seasonController();
    Jos_fastball_linescore jos_fastball_linescore1 = new Jos_fastball_linescore();
    Jos_fastball_linescoreController jos_fastball_linescoreController1 = new Jos_fastball_linescoreController();
    Jos_fastball_gamestatus jos_fastball_gamestatus1 = new Jos_fastball_gamestatus();
    Jos_fastball_gamestatusController jos_fastball_gamestatusController1 = new Jos_fastball_gamestatusController();
   
    DefaultTableModel modeloResultado, modeloResultado2, modeloResultado3;
   

    List<Jos_fastball_team> jos_fastball_teamlist = new ArrayList<>();
    List<Jos_fastball_player> jos_fastball_playerlist = new ArrayList<>();
    int fila = -1;
    Integer idtemporada = 0;
    Integer idequipovisitante = 0;
    Integer idpartido = 0;
    String equipolocal = "";
    String equipovisitante = "";
    Integer episodio = 0;
    Integer estatus = 0;
    String controlLlamado;
    JComboBox comboINN;
    String varControl = "started";
    StringBuilder sbMensajes = new StringBuilder();
    Integer idequipolocal;
    JLabel statusLabel = new JLabel();

    /**
     * Creates new form Anotaciones
     */
    public LivescoreFrame() {
        initComponents();
        if (SesionLocal.getIdtemporada() == -1) {
            Mensajeria.Mensaje("Debe seleccionar primero la temorada para utilizar esta opcion");
            dispose();
        }
        statusLabel.setForeground(Color.blue);

//        CargarTemporada();

//        CargarEstatus();
        jXStatusBar1.add(statusLabel);
        comboINN = new JComboBox();
        comboINN.addItem("--");
        comboINN.addItem("1/3");
        comboINN.addItem("2/3");

       

        modeloResultado = (DefaultTableModel) jTableResultado.getModel();
        modeloResultado2 = (DefaultTableModel) jTableResultado2.getModel();
        modeloResultado3 = (DefaultTableModel) jTableResultado3.getModel();


        if (!CargarListaEquipos()) {
            //   return;
        }
HiloIniciar();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jDialogAgregar = new javax.swing.JDialog();
        jPanel3 = new javax.swing.JPanel();
        jLabel10 = new javax.swing.JLabel();
        jTextFieldEquipoJugadores = new javax.swing.JTextField();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTableJugadores = new javax.swing.JTable();
        jButtonAgregar = new javax.swing.JButton();
        jButtonCerrar1 = new javax.swing.JButton();
        jDialogMensajesResultados = new javax.swing.JDialog();
        jLabel18 = new javax.swing.JLabel();
        jScrollPane8 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jPanel1 = new javax.swing.JPanel();
        jButton7 = new javax.swing.JButton();
        jDialogIning = new javax.swing.JDialog();
        jLabel17 = new javax.swing.JLabel();
        jTextFieldEpisodiosDialogo = new javax.swing.JTextField();
        jButton8 = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jXComboBoxPartido = new org.jdesktop.swingx.JXComboBox();
        jLabel8 = new javax.swing.JLabel();
        jXComboBoxTemporada = new org.jdesktop.swingx.JXComboBox();
        jLabel15 = new javax.swing.JLabel();
        jTextFieldIdPartido = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        jTextFieldEstatusOld = new javax.swing.JTextField();
        jPanel5 = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        jXComboBoxEstatus = new org.jdesktop.swingx.JXComboBox();
        jButtonGuardar = new javax.swing.JButton();
        jButtonCerrar = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        jTextFieldEpisodios = new javax.swing.JTextField();
        jButtonEstablecerEpisodios = new javax.swing.JButton();
        jXStatusBar1 = new org.jdesktop.swingx.JXStatusBar();
        jPanel4 = new javax.swing.JPanel();
        jLabelFotoLocal1 = new javax.swing.JLabel();
        jLabelFotoVisitante1 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jTextFieldTipo = new javax.swing.JTextField();
        jButtonCargar = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jTextFieldFecha = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jTextFieldEstadio = new javax.swing.JTextField();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanelResultado = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jTextFieldLocal = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jTextFieldVisitante = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTableResultado = new javax.swing.JTable();
        jScrollPane5 = new javax.swing.JScrollPane();
        jTableResultado2 = new javax.swing.JTable();
        jScrollPane6 = new javax.swing.JScrollPane();
        jTableResultado3 = new javax.swing.JTable();
        jButtonActualizarIning = new javax.swing.JButton();

        jDialogAgregar.setAlwaysOnTop(true);

        jLabel10.setText("Equipo");

        jTextFieldEquipoJugadores.setEditable(false);
        jTextFieldEquipoJugadores.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldEquipoJugadoresActionPerformed(evt);
            }
        });

        jTableJugadores.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "", "ord", "id", "#", "Jugador"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Boolean.class, java.lang.Integer.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class
            };
            boolean[] canEdit = new boolean [] {
                true, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane3.setViewportView(jTableJugadores);
        jTableJugadores.getColumnModel().getColumn(0).setPreferredWidth(20);
        jTableJugadores.getColumnModel().getColumn(1).setPreferredWidth(60);
        jTableJugadores.getColumnModel().getColumn(2).setPreferredWidth(60);
        jTableJugadores.getColumnModel().getColumn(3).setPreferredWidth(60);
        jTableJugadores.getColumnModel().getColumn(4).setPreferredWidth(300);

        jButtonAgregar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/add.png"))); // NOI18N
        jButtonAgregar.setText("Agregar");
        jButtonAgregar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAgregarActionPerformed(evt);
            }
        });

        jButtonCerrar1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/return.png"))); // NOI18N
        jButtonCerrar1.setText("Cerrar");
        jButtonCerrar1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCerrar1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel10)
                                .addGap(18, 18, 18)
                                .addComponent(jTextFieldEquipoJugadores, javax.swing.GroupLayout.PREFERRED_SIZE, 334, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 452, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(50, 50, 50)
                        .addComponent(jButtonAgregar)
                        .addGap(52, 52, 52)
                        .addComponent(jButtonCerrar1)))
                .addContainerGap(67, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jTextFieldEquipoJugadores, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 369, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButtonAgregar, javax.swing.GroupLayout.DEFAULT_SIZE, 43, Short.MAX_VALUE)
                    .addComponent(jButtonCerrar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        javax.swing.GroupLayout jDialogAgregarLayout = new javax.swing.GroupLayout(jDialogAgregar.getContentPane());
        jDialogAgregar.getContentPane().setLayout(jDialogAgregarLayout);
        jDialogAgregarLayout.setHorizontalGroup(
            jDialogAgregarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jDialogAgregarLayout.setVerticalGroup(
            jDialogAgregarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialogAgregarLayout.createSequentialGroup()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        jDialogMensajesResultados.addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                jDialogMensajesResultadosWindowClosed(evt);
            }
            public void windowClosing(java.awt.event.WindowEvent evt) {
                jDialogMensajesResultadosWindowClosing(evt);
            }
        });

        jLabel18.setText("INFORMES DEL PROCESO");

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jScrollPane8.setViewportView(jTextArea1);

        jButton7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/return.png"))); // NOI18N
        jButton7.setText("Cerrar");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(26, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jDialogMensajesResultadosLayout = new javax.swing.GroupLayout(jDialogMensajesResultados.getContentPane());
        jDialogMensajesResultados.getContentPane().setLayout(jDialogMensajesResultadosLayout);
        jDialogMensajesResultadosLayout.setHorizontalGroup(
            jDialogMensajesResultadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialogMensajesResultadosLayout.createSequentialGroup()
                .addGroup(jDialogMensajesResultadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jDialogMensajesResultadosLayout.createSequentialGroup()
                        .addGap(160, 160, 160)
                        .addComponent(jLabel18))
                    .addGroup(jDialogMensajesResultadosLayout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 563, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jDialogMensajesResultadosLayout.createSequentialGroup()
                        .addGap(193, 193, 193)
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(22, Short.MAX_VALUE))
        );
        jDialogMensajesResultadosLayout.setVerticalGroup(
            jDialogMensajesResultadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialogMensajesResultadosLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel18)
                .addGap(42, 42, 42)
                .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 281, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(27, Short.MAX_VALUE))
        );

        jDialogIning.setTitle("Ining Jugados");

        jLabel17.setText("Episodios Jugados");

        jTextFieldEpisodiosDialogo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldEpisodiosDialogoActionPerformed(evt);
            }
        });

        jButton8.setText("Aceptar");
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jDialogIningLayout = new javax.swing.GroupLayout(jDialogIning.getContentPane());
        jDialogIning.getContentPane().setLayout(jDialogIningLayout);
        jDialogIningLayout.setHorizontalGroup(
            jDialogIningLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialogIningLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel17)
                .addGap(18, 18, 18)
                .addComponent(jTextFieldEpisodiosDialogo, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(29, 29, 29)
                .addComponent(jButton8)
                .addContainerGap(108, Short.MAX_VALUE))
        );
        jDialogIningLayout.setVerticalGroup(
            jDialogIningLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialogIningLayout.createSequentialGroup()
                .addGap(86, 86, 86)
                .addGroup(jDialogIningLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(jTextFieldEpisodiosDialogo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton8))
                .addContainerGap(102, Short.MAX_VALUE))
        );

        setResizable(true);
        setTitle("LIVE SCORE");
        setToolTipText("");

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Partido"));
        jPanel2.setEnabled(false);

        jLabel1.setText("Partido");

        jXComboBoxPartido.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jXComboBoxPartidoActionPerformed(evt);
            }
        });

        jLabel8.setText("Temporada");

        jXComboBoxTemporada.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jXComboBoxTemporadaActionPerformed(evt);
            }
        });

        jLabel15.setText("id");

        jTextFieldIdPartido.setEditable(false);

        jLabel16.setText("Estado");

        jTextFieldEstatusOld.setEditable(false);

        jPanel5.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel9.setText("Nuevo Estatus");

        jXComboBoxEstatus.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jXComboBoxEstatusActionPerformed(evt);
            }
        });

        jButtonGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/save.gif"))); // NOI18N
        jButtonGuardar.setText("Guardar  Estatus");
        jButtonGuardar.setEnabled(false);
        jButtonGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGuardarActionPerformed(evt);
            }
        });

        jButtonCerrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/return.png"))); // NOI18N
        jButtonCerrar.setText("Cerrar");
        jButtonCerrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCerrarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel9)
                        .addGap(18, 18, 18)
                        .addComponent(jXComboBoxEstatus, javax.swing.GroupLayout.PREFERRED_SIZE, 230, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGap(89, 89, 89)
                        .addComponent(jButtonGuardar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButtonCerrar)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jXComboBoxEstatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonGuardar, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonCerrar, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jLabel7.setText("Numero de episodios");

        jTextFieldEpisodios.setEditable(false);
        jTextFieldEpisodios.setText("0");
        jTextFieldEpisodios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldEpisodiosActionPerformed(evt);
            }
        });

        jButtonEstablecerEpisodios.setText("Establecer Cantidad Episodios");
        jButtonEstablecerEpisodios.setEnabled(false);
        jButtonEstablecerEpisodios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonEstablecerEpisodiosActionPerformed(evt);
            }
        });

        jXStatusBar1.setForeground(java.awt.Color.red);
        jXStatusBar1.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N

        jLabelFotoLocal1.setText(".");

        jLabelFotoVisitante1.setText(".");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabelFotoLocal1, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(39, 39, 39)
                .addComponent(jLabelFotoVisitante1, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(122, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelFotoLocal1, javax.swing.GroupLayout.DEFAULT_SIZE, 76, Short.MAX_VALUE)
                    .addComponent(jLabelFotoVisitante1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        jLabel6.setText("Cal/Ronda");

        jTextFieldTipo.setEditable(false);

        jButtonCargar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/download.png"))); // NOI18N
        jButtonCargar.setText("Cargar");
        jButtonCargar.setEnabled(false);
        jButtonCargar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCargarActionPerformed(evt);
            }
        });

        jLabel4.setText("Fecha");

        jTextFieldFecha.setEditable(false);

        jLabel5.setText("Estadio");

        jTextFieldEstadio.setEditable(false);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addGap(18, 18, 18)
                        .addComponent(jTextFieldEpisodios, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonEstablecerEpisodios)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel4))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel8)
                            .addComponent(jLabel1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jXComboBoxPartido, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jXComboBoxTemporada, javax.swing.GroupLayout.DEFAULT_SIZE, 618, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButtonCargar, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jXStatusBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 804, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jTextFieldFecha, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel5)
                                .addGap(29, 29, 29)
                                .addComponent(jTextFieldEstadio))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel16)
                                .addGap(18, 18, 18)
                                .addComponent(jTextFieldEstatusOld, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel15)
                                .addGap(18, 18, 18)
                                .addComponent(jTextFieldIdPartido, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(47, 47, 47)
                                .addComponent(jLabel6)
                                .addGap(30, 30, 30)
                                .addComponent(jTextFieldTipo, javax.swing.GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE)))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 28, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(158, 158, 158))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8)
                            .addComponent(jXComboBoxTemporada, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(10, 10, 10)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(jXComboBoxPartido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButtonCargar, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel7)
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jTextFieldEpisodios, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jButtonEstablecerEpisodios)
                                .addComponent(jLabel4)
                                .addComponent(jTextFieldFecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel16)
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jTextFieldEstatusOld, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel15)
                                .addComponent(jTextFieldIdPartido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel6)
                                .addComponent(jTextFieldTipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGap(6, 6, 6)
                                .addComponent(jLabel5))
                            .addComponent(jTextFieldEstadio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(11, 11, 11)
                        .addComponent(jXStatusBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(0, 14, Short.MAX_VALUE))
        );

        jLabel2.setText("Local");

        jTextFieldLocal.setEditable(false);
        jTextFieldLocal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldLocalActionPerformed(evt);
            }
        });

        jLabel3.setText("Visitante");

        jTextFieldVisitante.setEditable(false);
        jTextFieldVisitante.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldVisitanteActionPerformed(evt);
            }
        });

        jTableResultado.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Equipo", "1", "2", "3", "4", "5", "6", "7", "8", "9", "C", "H", "E"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Object.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class
            };
            boolean[] canEdit = new boolean [] {
                false, true, true, true, true, true, true, true, true, true, true, true, true
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(jTableResultado);

        jTableResultado2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Equipo", "10", "11", "12", "13", "14", "15", "16", "17", "18"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Object.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class
            };
            boolean[] canEdit = new boolean [] {
                false, true, true, true, true, true, true, true, true, true
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane5.setViewportView(jTableResultado2);

        jTableResultado3.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Equipo", "19", "20", "21", "22", "23", "24", "25", "26", "27"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Object.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class
            };
            boolean[] canEdit = new boolean [] {
                false, true, true, true, true, true, true, true, true, true
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane6.setViewportView(jTableResultado3);

        jButtonActualizarIning.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/ok.png"))); // NOI18N
        jButtonActualizarIning.setText("Actualizar Ining");
        jButtonActualizarIning.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonActualizarIningActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelResultadoLayout = new javax.swing.GroupLayout(jPanelResultado);
        jPanelResultado.setLayout(jPanelResultadoLayout);
        jPanelResultadoLayout.setHorizontalGroup(
            jPanelResultadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelResultadoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelResultadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelResultadoLayout.createSequentialGroup()
                        .addGap(5, 5, 5)
                        .addComponent(jLabel2)
                        .addGap(38, 38, 38)
                        .addComponent(jTextFieldLocal, javax.swing.GroupLayout.PREFERRED_SIZE, 254, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(204, 204, 204)
                        .addComponent(jLabel3)
                        .addGap(18, 18, 18)
                        .addComponent(jTextFieldVisitante, javax.swing.GroupLayout.PREFERRED_SIZE, 254, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanelResultadoLayout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 960, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(40, 40, 40)
                        .addComponent(jButtonActualizarIning))
                    .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 960, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 960, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(271, Short.MAX_VALUE))
        );
        jPanelResultadoLayout.setVerticalGroup(
            jPanelResultadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelResultadoLayout.createSequentialGroup()
                .addGap(17, 17, 17)
                .addGroup(jPanelResultadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelResultadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel2)
                        .addComponent(jTextFieldLocal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanelResultadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel3)
                        .addComponent(jTextFieldVisitante, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(jPanelResultadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelResultadoLayout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jButtonActualizarIning, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(177, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Resultado", jPanelResultado);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 1427, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 573, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(20, 20, 20))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonCerrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCerrarActionPerformed
        dispose();
    }//GEN-LAST:event_jButtonCerrarActionPerformed

    private void jXComboBoxPartidoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jXComboBoxPartidoActionPerformed
    }//GEN-LAST:event_jXComboBoxPartidoActionPerformed

    private void jTextFieldVisitanteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldVisitanteActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldVisitanteActionPerformed

    private void jTextFieldLocalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldLocalActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldLocalActionPerformed

    private void jXComboBoxTemporadaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jXComboBoxTemporadaActionPerformed
        try {
            int a = jXComboBoxTemporada.getSelectedIndex();
            if (a != -1) {
                jos_fastball_season1 = jos_fastball_seasonContoller1.getJos_fastball_seasonlist().get(a);
                this.idtemporada = jos_fastball_season1.getId();

                CargarAgenda();
            }

        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "ComboBoxTemporada()");
        }

    }//GEN-LAST:event_jXComboBoxTemporadaActionPerformed

    private void jButtonCargarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCargarActionPerformed

        try {
            HiloCargar();
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "Boton Cargar()");
        }

    }//GEN-LAST:event_jButtonCargarActionPerformed

    private boolean ProcesoInicial() {
        try {
            LimpiarModelo(modeloResultado);
            LimpiarModelo(modeloResultado2);
            LimpiarModelo(modeloResultado3);

            updateProgress("procesando partidos...");
            int a = jXComboBoxPartido.getSelectedIndex();

            if (a != -1) {
                jos_fastball_schedule1 = jos_fastball_scheduleController1.getJos_fastball_schedulelist().get(a);
                this.idpartido = jos_fastball_schedule1.getId();
                jTextFieldIdPartido.setText(this.idpartido.toString());
                this.idequipolocal = jos_fastball_schedule1.getHometeam();
                /*
                 *
                 */
                updateProgress("procesando partido " + this.idpartido);
                Jos_fastball_gamestatus jos_fastball_gamestatus = new Jos_fastball_gamestatus();
                Jos_fastball_gamestatusController jos_fastball_gamestatusController = new Jos_fastball_gamestatusController();
                jos_fastball_gamestatus.setId(jos_fastball_schedule1.getStatus());
                updateProgress("buscando el estatus del juego " + this.idpartido);
                Jos_fastball_gamestatus jos_fastball_gamestatus2 = jos_fastball_gamestatusController.findByPrimaryKey(jos_fastball_gamestatus);
                if (jos_fastball_gamestatus2 != null) {
                    jTextFieldEstatusOld.setText(jos_fastball_gamestatus2.getDescription());
                } else {
                    jTextFieldEstatusOld.setText("");
                }
                updateProgress("cargando datos del equipo local....");

                equipolocal = ObtenerNombreEquipo(jos_fastball_schedule1.getHometeam());
                jTextFieldLocal.setText(equipolocal);
                jTextFieldEquipoJugadores.setText(equipolocal);


                CargarFotosLocales();
//jPanelHittingLocal.set
                this.idequipovisitante = jos_fastball_schedule1.getVisitingteam();

                jos_fastball_team1.setId(jos_fastball_schedule1.getVisitingteam());
                updateProgress("cargando datos del equipo visitante....");

                equipovisitante = ObtenerNombreEquipo(jos_fastball_schedule1.getVisitingteam());

                jTextFieldVisitante.setText(equipovisitante);
                jTextFieldFecha.setText(jos_fastball_schedule1.getGamedatetime().toString());
                CargarFotosVisitantes();
                /*
                 * tipo
                 */
                updateProgress("buscando el status del juego");
                jos_fastball_gametype1.setId(jos_fastball_schedule1.getGametype());
                Jos_fastball_gametype jos_fastball_gametype = jos_fastball_gametypeController1.findByPrimaryKey(jos_fastball_gametype1);
                if (jos_fastball_gametype == null) {
                    jTextFieldTipo.setText("");
                } else {
                    jTextFieldTipo.setText(jos_fastball_gametype.getDescription());
                }
                updateProgress("buscando la ubicacion");
                jos_fastball_location1.setId(jos_fastball_schedule1.getLocation());
                Jos_fastball_location jos_fastball_location = jos_fastball_locationController1.findByPrimaryKey(jos_fastball_location1);
                if (jos_fastball_location == null) {
                    jTextFieldEstadio.setText("");
                } else {
                    jTextFieldEstadio.setText(jos_fastball_location.getName());
                }

            }
            return true;
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "ProcesInicial()");
        }
        return false;
    }

    private boolean CargarListaEquipos() {
        try {
            updateProgress("Cargando los equipos");
            jos_fastball_teamlist.removeAll(jos_fastball_teamlist);
            if (!jos_fastball_teamController1.Listar()) {
                Mensajeria.Mensaje("No hay registros de equipos");
                return false;
            }
            jos_fastball_teamlist = jos_fastball_teamController1.getJos_fastball_teamlist();
            updateProgress(" ");
            return true;
        } catch (Exception ex) {
            Mensajeria.Mensaje("CargarListaEquipos()");
        }
        return false;
    }


    private void CargarFotosLocales() {
        try {
            jLabelFotoLocal1.setText("");
            switch (idequipolocal) {
                case 30:
                    jLabelFotoLocal1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/logos/Bocas.png"))); // NOI18N
                  
                    break;
                case 31:
                    jLabelFotoLocal1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/logos/Cocle.png"))); // NOI18N
                    break;
                case 32:
                    jLabelFotoLocal1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/logos/Colon.png"))); // NOI18N
                    break;
                case 33:
                    jLabelFotoLocal1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/logos/Chiriqui.png"))); // NOI18N
                    break;
                case 34:
                    jLabelFotoLocal1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/logos/Darien.png"))); // NOI18N
                    break;
                case 35:
                    jLabelFotoLocal1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/logos/Herrera.png"))); // NOI18N
                    break;
                case 36:
                    jLabelFotoLocal1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/logos/LosSantos.png"))); // NOI18N
                    break;
                case 37:
                    jLabelFotoLocal1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/logos/Metro.png"))); // NOI18N
                    break;
                case 38:
                    jLabelFotoLocal1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/logos/PanamaOeste.png"))); // NOI18N
                    break;
                case 39:
                    jLabelFotoLocal1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/logos/Veraguas.png"))); // NOI18N
                    break;
                    case 40:
                    jLabelFotoLocal1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/logos/Chiriquio.png"))); // NOI18N
                    break;
                    default :
                        jLabelFotoLocal1.setIcon(null);
            }

        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "CargarFotos Locales()");
        }
    }
    
       private void CargarFotosVisitantes() {
        try {
            jLabelFotoVisitante1.setText("");
            switch (idequipovisitante) {
                case 30:
                    jLabelFotoVisitante1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/logos/Bocas.png"))); // NOI18N
                  
                    break;
                case 31:
                    jLabelFotoVisitante1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/logos/Cocle.png"))); // NOI18N
                    break;
                case 32:
                    jLabelFotoVisitante1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/logos/Colon.png"))); // NOI18N
                    break;
                case 33:
                    jLabelFotoVisitante1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/logos/Chiriqui.png"))); // NOI18N
                    break;
                case 34:
                    jLabelFotoVisitante1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/logos/Darien.png"))); // NOI18N
                    break;
                case 35:
                    jLabelFotoVisitante1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/logos/Herrera.png"))); // NOI18N
                    break;
                case 36:
                    jLabelFotoVisitante1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/logos/LosSantos.png"))); // NOI18N
                    break;
                case 37:
                    jLabelFotoVisitante1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/logos/Metro.png"))); // NOI18N
                    break;
                case 38:
                    jLabelFotoVisitante1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/logos/PanamaOeste.png"))); // NOI18N
                    break;
                case 39:
                    jLabelFotoVisitante1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/logos/Veraguas.png"))); // NOI18N
                    break;
                    case 40:
                    jLabelFotoVisitante1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cuadroanotacion/resources/gif/logos/Chiriquio.png"))); // NOI18N
                    break;
                    default:
                        jLabelFotoVisitante1.setIcon(null);
            }

        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "CargarFotos Locales()");
        }
    }

    private boolean ConvertiraCero(String nmodelo, DefaultTableModel lmodelo, int columna) {
        try {
            updateProgress("Verificando que las columnas este en cero. Espere...");
            for (int fila = 0; fila < lmodelo.getRowCount(); fila++) {

                for (int col = columna; col < lmodelo.getColumnCount(); col++) {
                    if (nmodelo.equals("PitchingLocal") || nmodelo.equals("PitchingVisitante")) {
                        if (col == 5 || col == 17 || col == 18 || col == 19 || col == 20 || col == 21) {
                        } else {
                            if (lmodelo.getValueAt(fila, col) == null || lmodelo.getValueAt(fila, col).toString().equals("")) {
                                lmodelo.setValueAt(0, fila, col);
                            } else {
                                if (!isNumeric(lmodelo.getValueAt(fila, col).toString())) {
                                    Mensajeria.Mensaje("En la tabla: " + nmodelo + "\n El valor " + lmodelo.getValueAt(fila, col).toString() + "\n No es un numero");
                                    return false;
                                }
                            }

                        }
                    } else {
                        if (lmodelo.getValueAt(fila, col) == null || lmodelo.getValueAt(fila, col).toString().equals("")) {
                            lmodelo.setValueAt(0, fila, col);
                        } else {
                            if (!isNumeric(lmodelo.getValueAt(fila, col).toString())) {
                                Mensajeria.Mensaje("En la tabla: " + nmodelo + "\n El valor " + lmodelo.getValueAt(fila, col).toString() + "\n No es un numero");
                                return false;
                            }
                        }
                    }

                }//for col
            }//for fila
            return true;
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "ConvertiraCero() " + nmodelo);
        }
        return false;
    }

    private Integer PosicionMarcado(DefaultTableModel lmodelo, int columna) {
        try {
            for (int fila = 0; fila < lmodelo.getRowCount(); fila++) {
                if (lmodelo.getValueAt(fila, columna).equals(true)) {
                    return fila;
                }
            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "PosicionMarcado()");
        }
        return -1;
    }
    private void jButtonGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGuardarActionPerformed
        try {
            HiloGuardar();


        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "Guardar()");
        }
        //     jButtonGuardar.setEnabled(true);
    }//GEN-LAST:event_jButtonGuardarActionPerformed

    private void jXComboBoxEstatusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jXComboBoxEstatusActionPerformed
        try {
            int a = jXComboBoxEstatus.getSelectedIndex();
            if (a != -1) {
                jos_fastball_gamestatus1 = jos_fastball_gamestatusController1.getJos_fastball_gamestatuslist().get(a);
                this.estatus = jos_fastball_gamestatus1.getId();
                //   jButtonGuardar.setEnabled(true);
            }

        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "ComboBoxEstatus()");
        }
    }//GEN-LAST:event_jXComboBoxEstatusActionPerformed

    private void jTextFieldEquipoJugadoresActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldEquipoJugadoresActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldEquipoJugadoresActionPerformed

    private void jButtonCerrar1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCerrar1ActionPerformed
        jDialogAgregar.dispose();
    }//GEN-LAST:event_jButtonCerrar1ActionPerformed

    private void jButtonAgregarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAgregarActionPerformed
        try {

        
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "BotonAgregar()");
        }
    }//GEN-LAST:event_jButtonAgregarActionPerformed

    private void jButtonEstablecerEpisodiosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonEstablecerEpisodiosActionPerformed
        jDialogIning.setSize(564, 350);
        jDialogIning.setLocationRelativeTo(this);
        jDialogIning.setVisible(true);
        jButtonGuardar.setEnabled(true);
    }//GEN-LAST:event_jButtonEstablecerEpisodiosActionPerformed

    private void jTextFieldEpisodiosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldEpisodiosActionPerformed
        ProcesarIning();
    }//GEN-LAST:event_jTextFieldEpisodiosActionPerformed

    private void jTextFieldEpisodiosDialogoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldEpisodiosDialogoActionPerformed
        setIning();
    }//GEN-LAST:event_jTextFieldEpisodiosDialogoActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        setIning();
    }//GEN-LAST:event_jButton8ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed

        varControl = "save";
        LimpiarTodosLosDatos();
        jDialogMensajesResultados.dispose();
    }//GEN-LAST:event_jButton7ActionPerformed

    private void jDialogMensajesResultadosWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_jDialogMensajesResultadosWindowClosed
    }//GEN-LAST:event_jDialogMensajesResultadosWindowClosed

    private void jDialogMensajesResultadosWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_jDialogMensajesResultadosWindowClosing

        varControl = "save";
        LimpiarTodosLosDatos();
    }//GEN-LAST:event_jDialogMensajesResultadosWindowClosing

    private void jButtonActualizarIningActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonActualizarIningActionPerformed
      HiloActualizarInning();
    }//GEN-LAST:event_jButtonActualizarIningActionPerformed
    private void HiloIniciar() {
        Thread queryThread = new Thread() {

            public void run() {
                runQueries();
            }
        };
        queryThread.start();
    }

    private void HiloCargar() {
        Thread queryThread = new Thread() {

            public void run() {
                runQueriesCargar();
            }
        };
        queryThread.start();
    }

    private void HiloGuardar() {
        Thread queryThread = new Thread() {

            public void run() {
                runQueriesGuardar();
            }
        };
        queryThread.start();
    }
private void HiloActualizarInning() {
        Thread queryThread = new Thread() {

            public void run() {
                runQueriesActualizarIning();
            }
        };
        queryThread.start();
    }
    private void runQueries() {
        try {

            CargarTemporada();
            CargarEstatus();
   
            updateProgress("Ahora presione el boton CARGAR");

        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "runQueries()");
        }
    }

     private void runQueriesActualizarIning() {
        try {

           ActualizarIning();
         
            updateProgress("Ining actualizado");

        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "runQueries()");
        }
    }
    private void runQueriesCargar() {
        try {
            switch (varControl) {
                case "started":
                case "save":
                    varControl = "load";
                    break;
                case "load":
                    if (Mensajeria.PreguntaSiNo("El juego anterior no se ha guardado.\nSi Continua perdera los datos\nDesea cargar otro juego", "Cargar Juego Nuevo sin Guardar").equals("si")) {
                    } else {
                        return;
                    }
            }
            updateProgress("llamando al proceso inicial...");
            if (!ProcesoInicial()) {
                return;
            }
            updateProgress("limpiando tablas...");
            LimpiarModelo(modeloResultado);
            LimpiarModelo(modeloResultado2);
            LimpiarModelo(modeloResultado3);


            jDialogIning.setSize(564, 350);
            jDialogIning.setLocationRelativeTo(this);
            jDialogIning.setVisible(true);
            jButtonGuardar.setEnabled(true);
            jButtonEstablecerEpisodios.setEnabled(true);
            updateProgress("Registre los resultados del partido");

        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "runQueries()");
        }
    }

    private void runQueriesGuardar() {
        try {
            updateProgress("Verificando los datos para guardar...");
            sbMensajes.delete(0, sbMensajes.length());
            sbMensajes.append("\nProceso terminado");
            if (this.idpartido <= 0) {
                Mensajeria.Mensaje("Debe seleccionar un partido primero");
                jButtonGuardar.setEnabled(false);
                return;
            }
            this.episodio = Integer.parseInt(jTextFieldEpisodios.getText());

            if (this.episodio <= 0) {
                Mensajeria.Mensaje("El numero de episodios no debe ser cero o negativo");
                return;
            }
            int a = jXComboBoxEstatus.getSelectedIndex();
            if (a != -1) {
                jos_fastball_gamestatus1 = jos_fastball_gamestatusController1.getJos_fastball_gamestatuslist().get(a);
                this.estatus = jos_fastball_gamestatus1.getId();
                if (this.estatus == 1) {
                    Mensajeria.Mensaje("Debe cambiar el estatus del juego");
                    return;
                }

            } else {
                Mensajeria.Mensaje("Seleccione el estatus");
            }
            if (!ConvertiraCero("Resultado", modeloResultado, 1)) {
                return;
            }

            if (!ConvertiraCero("Resultado2", modeloResultado2, 1)) {
                return;
            }

            if (!ConvertiraCero("Resultado3", modeloResultado3, 1)) {
                return;
            }

          

            if (!VerificarMacador()) {
                return;
            }

            jButtonGuardar.setEnabled(false);
            if (!ActualizarCalendario()) {
                sbMensajes.append("\nNo se actualizo el calendario");

            } else {
                sbMensajes.append("\nSe actualizo el calendario");
            }
 String sql="idpartido='"+idpartido+"'";
             if(jos_fastball_linescoreController1.Eliminar(sql)){
                 
             }
            if (!GuardarIning()) {
                sbMensajes.append("\nNo se guardo los resultados de los ining");
            } else {
                sbMensajes.append("\nSe guardo los resultados de los ining");
            }
          
            jTextArea1.setText(sbMensajes.toString());
            jDialogMensajesResultados.setSize(664, 550);
            jDialogMensajesResultados.setLocationRelativeTo(this);
            jDialogMensajesResultados.setVisible(true);
            updateProgress("");
            updateProgress("");
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "runQueries()");
        }
    }

    private  void ActualizarIning(){
        try{
          
            if (!ConvertiraCero("Resultado", modeloResultado, 1)) {
                return;
            }

            if (!ConvertiraCero("Resultado2", modeloResultado2, 1)) {
                return;
            }

            if (!ConvertiraCero("Resultado3", modeloResultado3, 1)) {
                return;
            }
             
             String sql="gameid='"+idpartido+"'";
             if(jos_fastball_linescoreController1.Eliminar(sql)){
//                 Mensajeria.Mensaje("Se elimino los registros del linescore ");
             }
             else{
//                 Mensajeria.Mensaje("No se elimino los registros del linescore ");
             }
 if (!GuardarIning()) {
                sbMensajes.append("\nNo se guardo los resultados de los ining");
                Mensajeria.Mensaje("No se guardo los resultados del ining");
            } else {
                sbMensajes.append("\nSe guardo los resultados de los ining");
                Mensajeria.Mensaje("Ining guardado");
            }
          updateProgress("");
        }catch(Exception ex){
            Mensajeria.MensajeError(ex, "ActualizarIning()");
        }
    }
    private void ProcesarIning() {
        try {
            if (this.idpartido <= 0) {
                Mensajeria.Mensaje("Debe seleccionar un partido primero");
                return;
            }
            LimpiarModelo(modeloResultado);
            LimpiarModelo(modeloResultado2);
            LimpiarModelo(modeloResultado3);
            if (!isNumeric(jTextFieldEpisodios.getText())) {
                Mensajeria.Mensaje("El ining debe ser un numero");
                return;
            }
            this.episodio = Integer.parseInt(jTextFieldEpisodios.getText());

            if (this.episodio <= 0) {
                Mensajeria.Mensaje("El numero de episodios no debe ser cero o negativo");
                return;
            }
            Object[] filas = new Object[14];
            filas[0] = equipolocal;
            for (int i = 1; i < 13; i++) {
                filas[i] = "";
            }

            modeloResultado.addRow(filas);
            /*
             * visitante
             */
            filas[0] = equipovisitante;

            for (int i = 1; i < 13; i++) {
                filas[i] = "";
            }
            modeloResultado.addRow(filas);


            if (this.episodio > 9) {

                filas[0] = equipolocal;
                for (int i = 1; i < 13; i++) {
                    filas[i] = "";
                }

                modeloResultado2.addRow(filas);
                /*
                 * visitante
                 */
                filas[0] = equipovisitante;

                for (int i = 1; i < 13; i++) {
                    filas[i] = "";
                }
                modeloResultado2.addRow(filas);
            }
            if (this.episodio > 18) {

                filas[0] = equipolocal;
                for (int i = 1; i < 13; i++) {
                    filas[i] = "";
                }

                modeloResultado3.addRow(filas);
                /*
                 * visitante
                 */
                filas[0] = equipovisitante;

                for (int i = 1; i < 13; i++) {
                    filas[i] = "";
                }
                modeloResultado3.addRow(filas);
            }


        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "Ininig()");
        }
    }

    private void SeleccionarTodo(DefaultTableModel lmodelo, int columna) {
        try {
            for (int fila = 0; fila < lmodelo.getRowCount(); fila++) {
                lmodelo.setValueAt(true, fila, columna);

            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "SeleccionarTodo()");
        }
    }

    private void DeSeleccionarTodo(DefaultTableModel lmodelo, int columna) {
        try {
            for (int fila = 0; fila < lmodelo.getRowCount(); fila++) {
                lmodelo.setValueAt(false, fila, columna);

            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "SeleccionarTodo()");
        }
    }

   

    private void LimpiarTodosLosDatos() {
        try {
            idtemporada = 0;
            idequipolocal = 0;
            idequipovisitante = 0;
            idpartido = 0;
            equipolocal = "";
            equipovisitante = "";
            episodio = 0;
            estatus = 0;
            LimpiarModelo(modeloResultado);
            LimpiarModelo(modeloResultado2);
            LimpiarModelo(modeloResultado3);

            jTextFieldEpisodios.setText("");
            jTextFieldEpisodiosDialogo.setText("");
            jTextFieldEquipoJugadores.setText("");
            jTextFieldEstadio.setText("");
            jTextFieldEstatusOld.setText("");
            jTextFieldFecha.setText("");
            jTextFieldIdPartido.setText("");
            jTextFieldLocal.setText("");
           
            jTextFieldTipo.setText("");
            jTextFieldVisitante.setText("");


            HiloIniciar();

        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "Limpiar todos los datos()");
        }
    }

    private boolean VerificarMacador() {
        try {
            updateProgress("Verificando el marcador...");
            this.episodio = Integer.parseInt(jTextFieldEpisodios.getText());
            if (this.episodio < 0) {
                Mensajeria.Mensaje("El  numero de episodio no es correcto");
                return false;
            }
            Integer totalCarrerasHome = 0;
            Integer totalCarrerasVisitante = 0;
            Integer carrera;
            for (int i = 1; i <= 9; i++) {

                carrera = Integer.parseInt(jTableResultado.getValueAt(0, i).toString());
                if (carrera < 0) {
                    Mensajeria.Mensaje("El numero de carreras del equipo " + this.equipolocal + " en el episodio: " + i + " No debe ser negativo");
                    return false;

                }
                totalCarrerasHome += carrera;

                carrera = Integer.parseInt(jTableResultado.getValueAt(1, i).toString());
                if (carrera < 0) {
                    Mensajeria.Mensaje("El numero de carreras del equipo " + this.equipovisitante + " en el episodio: " + i + " No debe ser negativo");
                    return false;

                }
                totalCarrerasVisitante += carrera;

            }
            if (this.episodio > 9) {
                for (int i = 1; i <= 9; i++) {

                    carrera = Integer.parseInt(jTableResultado2.getValueAt(0, i).toString());
                    if (carrera < 0) {
                        Mensajeria.Mensaje("El numero de carreras del equipo " + this.equipolocal + " en el episodio: " + i + " No debe ser negativo");
                        return false;

                    }
                    totalCarrerasHome += carrera;

                    carrera = Integer.parseInt(jTableResultado2.getValueAt(1, i).toString());
                    if (carrera < 0) {
                        Mensajeria.Mensaje("El numero de carreras del equipo " + this.equipovisitante + " en el episodio: " + i + " No debe ser negativo");
                        return false;

                    }
                    totalCarrerasVisitante += carrera;

                }
            }
            if (this.episodio > 18) {
                for (int i = 1; i <= 9; i++) {
                    carrera = Integer.parseInt(jTableResultado3.getValueAt(0, i).toString());
                    if (carrera < 0) {
                        Mensajeria.Mensaje("El numero de carreras del equipo " + this.equipolocal + " en el episodio: " + i + " No debe ser negativo");
                        return false;

                    }
                    totalCarrerasHome += carrera;

                    carrera = Integer.parseInt(jTableResultado3.getValueAt(1, i).toString());
                    if (carrera < 0) {
                        Mensajeria.Mensaje("El numero de carreras del equipo " + this.equipovisitante + " en el episodio: " + i + " No debe ser negativo");
                        return false;

                    }
                    totalCarrerasVisitante += carrera;
                }
            }
            if (totalCarrerasHome != Integer.parseInt(modeloResultado.getValueAt(0, 10).toString())) {

                Mensajeria.Mensaje("El numero de carreras por episodio del equipo :" + this.equipolocal + " no coincide con el total ");
                return false;
            }
            if (totalCarrerasVisitante != Integer.parseInt(modeloResultado.getValueAt(1, 10).toString())) {
                Mensajeria.Mensaje("El numero de carreras por episodio del equipo :" + this.equipovisitante + " no coincide con el total ");
                return false;
            }
            if (totalCarrerasHome == 0 && totalCarrerasVisitante == 0) {

                if (Mensajeria.PreguntaSiNo("No se han registrado las carreras del juego\nEl juego quedo 0 a 0 esta seguro de esto?", "Empate a cero").equals("si")) {
                    return true;

                } else {
                    return false;
                }
            }
            return true;
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "VerificarMarcador()");
        }
        return false;
    }

    private boolean GuardarIning() {
        try {
            updateProgress("Iniciando el proceso de guardar los ining...");
            this.episodio = Integer.parseInt(jTextFieldEpisodios.getText());
            if (this.episodio < 0) {
                Mensajeria.Mensaje("El  numero de episodio no es correcto");
                return false;
            }

            for (int i = 1; i <= 9; i++) {
                jos_fastball_linescore1.setGameid(idpartido);
                jos_fastball_linescore1.setInning(i);
                jos_fastball_linescore1.setRunshome(Integer.parseInt(jTableResultado.getValueAt(0, i).toString()));
                jos_fastball_linescore1.setRunsaway(Integer.parseInt(jTableResultado.getValueAt(1, i).toString()));
                if (jos_fastball_linescoreController1.Crear(jos_fastball_linescore1)) {
                    updateProgress("Guardando inining " + i);
                } else {
                    sbMensajes.append("\nNo se pudo guardar el episodio " + i + " del primer marcador ");
                     updateProgress("No se pudo guardar el episodio " + i + " del primer marcador "+jos_fastball_linescoreController1.getMensaje());
                }
            }
            if (this.episodio > 9) {
                for (int i = 1; i <= 9; i++) {
                    jos_fastball_linescore1.setGameid(idpartido);
                    jos_fastball_linescore1.setInning(i);
                    jos_fastball_linescore1.setRunshome(Integer.parseInt(jTableResultado2.getValueAt(0, i).toString()));
                    jos_fastball_linescore1.setRunsaway(Integer.parseInt(jTableResultado2.getValueAt(1, i).toString()));
                    if (jos_fastball_linescoreController1.Crear(jos_fastball_linescore1)) {
                        updateProgress("Guardando ininig..." + i);
                    } else {
                        sbMensajes.append("\nNo se pudo guardar el episodio " + i + " del segundo marcador");
                         updateProgress("No se pudo guardar el episodio " + i + " del segundo marcador "+jos_fastball_linescoreController1.getMensaje());
                    }
                }
            }
            if (this.episodio > 18) {
                for (int i = 1; i <= 9; i++) {
                    jos_fastball_linescore1.setGameid(idpartido);
                    jos_fastball_linescore1.setInning(i);
                    jos_fastball_linescore1.setRunshome(Integer.parseInt(jTableResultado3.getValueAt(0, i).toString()));
                    jos_fastball_linescore1.setRunsaway(Integer.parseInt(jTableResultado3.getValueAt(1, i).toString()));
                    if (jos_fastball_linescoreController1.Crear(jos_fastball_linescore1)) {
                        updateProgress("Guardando ininig..." + i);
                    } else {
                        sbMensajes.append("\nNo se pudo guardarn el episodio " + i + " del tercer marcador");
                          updateProgress("No se pudo guardar el episodio " + i + " del tercer marcador "+jos_fastball_linescoreController1.getMensaje());
                    }
                }
            }
            return true;
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "GuadarIning()");
            sbMensajes.append("\nGuardarIning() " + ex.getLocalizedMessage());
        }
        return false;
    }

    private void CargarTemporada() {
        try {
            updateProgress("limpiando combos espere....");
            jXComboBoxTemporada.removeAllItems();
            jos_fastball_season1.setId(SesionLocal.getIdtemporada());
            updateProgress("iniciando consulta de datos de la temporada....");
            if (jos_fastball_seasonContoller1.findById(jos_fastball_season1)) {

                for (Jos_fastball_season s : jos_fastball_seasonContoller1.getJos_fastball_seasonlist()) {
                    updateProgress("cargando temporada " + s.getName());
                    jXComboBoxTemporada.addItem(s.getName());
                }
                //jButtonCargar.setEnabled(true);
            } else {
                Mensajeria.Mensaje("No hay ninguna temporada activa");
                //  jButtonCargar.setEnabled(false);
            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "CargarTemporada()");
        }
    }

    private boolean ActualizarCalendario() {
        try {
            updateProgress("Actualizando calendario...");
            int a = jXComboBoxPartido.getSelectedIndex();
            if (a != -1) {
                jos_fastball_schedule1 = jos_fastball_scheduleController1.getJos_fastball_schedulelist().get(a);
                jos_fastball_schedule1.setStatus(estatus);
                jos_fastball_schedule1.setInnings(this.episodio);
                jos_fastball_schedule1.setRunshome(Integer.parseInt(jTableResultado.getValueAt(0, 10).toString()));
                jos_fastball_schedule1.setRunsaway(Integer.parseInt(jTableResultado.getValueAt(1, 10).toString()));
                jos_fastball_schedule1.setHitshome(Integer.parseInt(jTableResultado.getValueAt(0, 11).toString()));
                jos_fastball_schedule1.setHitsaway(Integer.parseInt(jTableResultado.getValueAt(1, 11).toString()));
                jos_fastball_schedule1.setErrorshome(Integer.parseInt(jTableResultado.getValueAt(0, 12).toString()));
                jos_fastball_schedule1.setErrorsaway(Integer.parseInt(jTableResultado.getValueAt(1, 12).toString()));
                if (jos_fastball_scheduleController1.Editar(jos_fastball_schedule1)) {
                    updateProgress("Calendario actualizado...");
                } else {
                    sbMensajes.append("\nNo se actualizo el calendario" + jos_fastball_scheduleController1.getMensaje());
                    return false;
                }
            }
            return true;
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "ActualizarCalendario()");
            sbMensajes.append("\nActualizarCalendario() " + ex.getLocalizedMessage());
        }
        return false;
    }

    private void CargarEstatus() {
        try {
            updateProgress("Cargando estatus...");
            jXComboBoxEstatus.removeAllItems();

            if (jos_fastball_gamestatusController1.Listar()) {
                for (Jos_fastball_gamestatus s : jos_fastball_gamestatusController1.getJos_fastball_gamestatuslist()) {
                    updateProgress("cargando combo con estatus ...." + s.getDescription());
                    jXComboBoxEstatus.addItem(s.getDescription());
                }
            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "CargarTemporada()");
        }
    }

    private void CargarAgenda() {
        try {
            jXComboBoxPartido.removeAllItems();
            jos_fastball_schedule1.setSeason(this.idtemporada);
            boolean existe = false;
            String sql = "season ='" + this.idtemporada + "' and status='1' order by id";

            if (jos_fastball_scheduleController1.Query(sql)) {
                for (Jos_fastball_schedule j : jos_fastball_scheduleController1.getJos_fastball_schedulelist()) {
                    String lequipolocal = ObtenerNombreEquipo(j.getHometeam());
                    String lequipovisitante = ObtenerNombreEquipo(j.getVisitingteam());
                    jXComboBoxPartido.addItem(j.getId() - SesionLocal.getDecrementarparamostrar() + " | " + j.getGamedatetime().toString() + " | " + lequipolocal + "  vs.  " + lequipovisitante);
                }
                jButtonCargar.setEnabled(true);
            } else {

                jButtonCargar.setEnabled(false);
            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "cargarAgenda()");
        }
    }

    private String ObtenerNombreEquipo(Integer lid) {
        try {
            String name = "";

            updateProgress("buscando el nombre del equipo " + lid + " espere....");

            for (Jos_fastball_team j : jos_fastball_teamlist) {
                if (lid.equals(j.getId())) {

                    return j.getName();
                }
            }

            return name;
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "ObtenerNombreEquipo()");
        }
        return "";
    }


    private void LimpiarModelo(DefaultTableModel lmodelo) {
        try {
            if (lmodelo != null) {
                while (lmodelo.getRowCount() > 0) {
                    lmodelo.removeRow(0);
                }
            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "LimpiarModelo()");
        }
    }

    private static boolean isNumeric(String cadena) {
        try {
            Integer.parseInt(cadena);
            return true;
        } catch (NumberFormatException nfe) {
            return false;
        }
    }

    private void updateProgress(final String texto) {
        SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                // Here, we can safely update the GUI
                // because we'll be called from the
                // event dispatch thread
//                 statusLabel.setText( texto+ " : " + queryNo);
                statusLabel.setText(texto);
            }
        });
    }

    private void setIning() {
        try {
            String ln = jTextFieldEpisodiosDialogo.getText();
            if (isNumeric(ln)) {
                this.episodio = Integer.parseInt(ln);
                jTextFieldEpisodios.setText(ln);
                ProcesarIning();
                jDialogIning.dispose();
            } else {
                Mensajeria.Mensaje("Debe introducir la cantidad de episodios jugados");
                return;
            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "Boton setIninig()");
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButtonActualizarIning;
    private javax.swing.JButton jButtonAgregar;
    private javax.swing.JButton jButtonCargar;
    private javax.swing.JButton jButtonCerrar;
    private javax.swing.JButton jButtonCerrar1;
    private javax.swing.JButton jButtonEstablecerEpisodios;
    private javax.swing.JButton jButtonGuardar;
    private javax.swing.JDialog jDialogAgregar;
    private javax.swing.JDialog jDialogIning;
    private javax.swing.JDialog jDialogMensajesResultados;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLabelFotoLocal1;
    private javax.swing.JLabel jLabelFotoVisitante1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanelResultado;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTableJugadores;
    private javax.swing.JTable jTableResultado;
    private javax.swing.JTable jTableResultado2;
    private javax.swing.JTable jTableResultado3;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextField jTextFieldEpisodios;
    private javax.swing.JTextField jTextFieldEpisodiosDialogo;
    private javax.swing.JTextField jTextFieldEquipoJugadores;
    private javax.swing.JTextField jTextFieldEstadio;
    private javax.swing.JTextField jTextFieldEstatusOld;
    private javax.swing.JTextField jTextFieldFecha;
    private javax.swing.JTextField jTextFieldIdPartido;
    private javax.swing.JTextField jTextFieldLocal;
    private javax.swing.JTextField jTextFieldTipo;
    private javax.swing.JTextField jTextFieldVisitante;
    private org.jdesktop.swingx.JXComboBox jXComboBoxEstatus;
    private org.jdesktop.swingx.JXComboBox jXComboBoxPartido;
    private org.jdesktop.swingx.JXComboBox jXComboBoxTemporada;
    private org.jdesktop.swingx.JXStatusBar jXStatusBar1;
    // End of variables declaration//GEN-END:variables
}
